package com.gitee.wsl.time.clock

import kotlin.time.Clock
import kotlin.time.Duration
import kotlin.time.ExperimentalTime


@OptIn(ExperimentalTime::class)
private class OffsetClock(private val offset: Duration, private val base: Clock) : Clock {
    override fun now() = base.now() + offset
}

/**
 * Offset a [Clock].
 *
 * @param delta The delta by which to create an offset [Clock].
 */
@OptIn(ExperimentalTime::class)
fun Clock.offset(delta: Duration): Clock = OffsetClock(delta, this)
